package com.dsp.sharding.order.service.impl;

import com.dsp.sharding.order.dao.OrderDao;
import com.dsp.sharding.order.dao.OrderItemDao;
import com.dsp.sharding.order.entity.Order;
import com.dsp.sharding.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderDao orderDao;
    @Resource
    private OrderItemDao orderItemDao;

    public List<Order> findAll(){
        return (List<Order>) orderDao.findAll();
    }

    @Override
    @Transactional
    public void add() {
        orderDao.insert(100L,"1",100L,"dd");
        orderDao.insert(102L,"2",101L,"tt");
        orderDao.insert(103L,"3",102L,"aa");
        orderDao.insert(104L,"4",103L,"ff");
        List<Order> list = this.findAll();
        System.out.println(list.size());
    }

}
